package wangjg.mda.model.obj;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

public class Method implements Element {
	private String name;
	private String description;
	private List<Parameter> parameters;
	private String returnType;
	private String returnDescription;
	private List<String> throwz;
	private Map<String, String> throwDesMap;
	private String modifiers;
	private Map attributes;
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public List<Parameter> getParameters() {
		return parameters;
	}
	public void setParameters(List<Parameter> parameters) {
		this.parameters = parameters;
	}
	public String getReturnType() {
		return returnType;
	}
	public void setReturnType(String returnType) {
		this.returnType = returnType;
	}
	public String getReturnDescription() {
		return returnDescription;
	}
	public void setReturnDescription(String returnDescription) {
		this.returnDescription = returnDescription;
	}
	public List<String> getThrowz() {
		return throwz;
	}
	public void setThrowz(List<String> throwz) {
		this.throwz = throwz;
	}
	public String getModifiers() {
		return modifiers;
	}
	public void setModifiers(String modifiers) {
		this.modifiers = modifiers;
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result
				+ ((parameters == null) ? 0 : parameters.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Method other = (Method) obj;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (parameters == null) {
			if (other.parameters != null)
				return false;
		} else if (!parameters.equals(other.parameters))
			return false;
		return true;
	}
	public Map<String, String> getThrowDesMap() {
		return throwDesMap;
	}
	public void setThrowDesMap(Map<String, String> throwDesMap) {
		this.throwDesMap = throwDesMap;
	}
	public Map getAttributes() {
		return attributes;
	}
	public void setAttributes(Map attributes) {
		this.attributes = attributes;
	}
	
	public void setAttribute(String key, Object value){
		if(value==null){
			return ;
		}
		if(this.attributes==null){
			this.attributes = new LinkedHashMap();
		}
		this.attributes.put(key, value);
	}
	@Override
	public String toString() {
		return "\n\tMethod [name=" + name + ", description=" + description
				+ ", parameters=" + parameters + ", returnType=" + returnType
				+ ", returnDescription=" + returnDescription + ", throwz="
				+ throwz + ", throwDesMap=" + throwDesMap + ", modifiers="
				+ modifiers + ", \n\t\tattributes=" + attributes + "]";
	}
}
